package com.lakeworks.web.controller.core;

import com.lakeworks.common.core.controller.BaseController;
import com.lakeworks.common.core.domain.AjaxResult;
import com.lakeworks.common.core.page.TableDataInfo;
import com.lakeworks.domain.status.StaShipment;
import com.lakeworks.service.IStaShipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 出厂单状态Controller
 *
 * @author lake
 * @date 2023-02-23
 */
@RestController
@RequestMapping("/post/shipment")
public class StaShipmentController extends BaseController {
    @Autowired
    private IStaShipmentService staShipmentService;

    /**
     * 查询出厂单状态列表
     */
    @GetMapping("/list")
    public TableDataInfo list(StaShipment staShipment) {
        startPage();
        List<StaShipment> list = staShipmentService.selectStaShipmentList(staShipment);
        return getDataTable(list);
    }

//    /**
//     * 导出出厂单状态列表
//     */
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, StaShipment staShipment)
//    {
//        List<StaShipment> list = staShipmentService.selectStaShipmentList(staShipment);
//        ExcelUtil<StaShipment> util = new ExcelUtil<StaShipment>(StaShipment.class);
//        util.exportExcel(response, list, "出厂单状态数据");
//    }

    /**
     * 获取出厂单状态详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(staShipmentService.selectStaShipmentById(id));
    }

    /**
     * 新增出厂单状态
     */
    @PostMapping
    public AjaxResult add(@RequestBody StaShipment staShipment) {
        return toAjax(staShipmentService.insertStaShipment(staShipment));
    }

    /**
     * 修改出厂单状态
     */
    @PutMapping
    public AjaxResult edit(@RequestBody StaShipment staShipment) {
        return toAjax(staShipmentService.updateStaShipment(staShipment));
    }

    /**
     * 删除出厂单状态
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(staShipmentService.deleteStaShipmentByIds(ids));
    }
}
